﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;
namespace Nhom16_PTTKHTTT_12HCB
{
    public partial class frmThemNCC_NVL : Form
    {
        NguyenVatLieu_BUS nvl_bus;
        NCC_BUS ncc_bus;
        CTNCC ctncc_dto;
        CTNCC_BUS ctncc_bus;
        public frmThemNCC_NVL()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmThemNCC_NVL_Load(object sender, EventArgs e)
        {
            //load ten nguyen vat lieu
            nvl_bus = new NguyenVatLieu_BUS();
            cbxTenNVL_PN.DataSource = nvl_bus.DanhSachNVL();
            cbxTenNVL_PN.DisplayMember = "TenNVL";
            cbxTenNVL_PN.ValueMember = "MaNVL";
            //load danh sach nha cung cap
            ncc_bus = new NCC_BUS();
            cbxNCC_PNPX.DataSource = ncc_bus.DanhSachNCC();
            cbxNCC_PNPX.DisplayMember = "TenNCC";
            cbxNCC_PNPX.ValueMember = "MaNCC";
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            ctncc_bus = new CTNCC_BUS();
            ctncc_dto = new CTNCC();
            ctncc_dto.MaNCC = cbxNCC_PNPX.SelectedValue.ToString();
            ctncc_dto.MaNVL = cbxTenNVL_PN.SelectedValue.ToString();
            if (ctncc_bus.ThemCTNCC(ctncc_dto) == true)
            {
                MessageBox.Show("Thêm thành công", "Thông báo");
            }
            else
                MessageBox.Show("Nguyên vật liệu này đã được cung cấp bởi nhà cung cấp này","Thông báo");
        }
    }
}
